<template>
    <div class="index-lists">
        <el-card class="!border-none" shadow="never">
            <el-form
                ref="formRef"
                class="mb-[-16px]"
                :model="queryParams"
                :inline="true"
                label-width="244px"
            >
                <div style="float: right">
                    <el-form-item prop="ourRef">
                        <el-input class="w-[280px]" v-model="queryParams.ourRef" />
                    </el-form-item>
                    <!-- <el-form-item label="案件名称" prop="caseName">
          <el-input class="w-[280px]" v-model="queryParams.caseName" />
        </el-form-item>
        <el-form-item label="申请号" prop="test">
          <el-input class="w-[280px]" v-model="queryParams.test" />
        </el-form-item> -->
                    <el-form-item>
                        <el-button type="primary" @click="resetPage">查询</el-button>
                        <el-button @click="resetParams">重置</el-button>
                    </el-form-item>
                </div>
            </el-form>
        </el-card>
        <el-card class="!border-none mt-4" shadow="never">
            <el-table class="mt-4" size="large" v-loading="pager.loading" :data="pager.lists" stripe>
                <el-table-column label="我方文号" prop="ourRef" min-width="180">
                    <template #default="{ row }">
                        <router-link
                            style="color: #409EFF"
                            :to="{
                                path: getRoutePath('case:pendinginfo'),
                                query: {
                                    id: row.id,
                                    type: '1'
                                }
                            }"
                        >
                            {{ row.ourRef }}
                        </router-link>
                    </template>
                </el-table-column>
                <el-table-column label="案件名称" prop="caseName" min-width="180" />
                <el-table-column label="客户名称" prop="test" min-width="180" />
                <el-table-column label="客户代码" prop="test" min-width="180" />
                <el-table-column label="处理事项" prop="handlingInformation" min-width="180" />
                <el-table-column label="申请类型" prop="putinType" min-width="180" />
                <el-table-column label="当前流程" prop="test" min-width="180" />
                <el-table-column label="审核人员" prop="test" min-width="180" />
                <el-table-column label="内部/客户期限" prop="internalWearLife" min-width="180" />
                <el-table-column label="处理人" prop="test" min-width="180" />
                <!-- <el-table-column label="操作" width="120" fixed="right">
          <template #default="{ row }">
            <el-button
              v-perms="['case:del']"
              type="danger"
              link
              @click="handleDelete(row.id)"
            >
              删除
            </el-button>
          </template>
        </el-table-column> -->
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
        <edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
    </div>
</template>
<script lang="ts" setup name="case">
import { caseDelete, caseLists } from '@/api/case'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import { getRoutePath } from '@/router'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
const queryParams = reactive({
    caseName: '',
    caseType: '',
    businessType: '',
    putinType: '',
    undertakingDepartment: '',
    conductor: '',
    taxRate: '',
    costType: '',
    cost: '',
    contributionPool: '',
    ownershipDistribution: '',
    haveCase: '',
    designatedCountry: '',
    brandType: '',
    classQuantity: '',
    quantity: '',
    officialFee: '',
    agencyFee: '',
    hirdPartyPayment: '',
    signedAmount: '',
    invoiceValue: '',
    fundsReceived: '',
    paidupDateStart: '',
    paidupDateEnd: '',
    planNumber: '',
    caseStatus: '',
    caseLink: '',
    remark: '',
    caseNameid: '',
    businessTypeid: '',
    undertakingDepartmentid: '',
    ownershipDistributionid: '',
    costTypeid: '',
    correlationTypeid: '',
    isRegister: '',
    isInvalid: '',
    isExistingcase: '',
    isPapernotice: '',
    customerDocumentNumber: '',
    copyrightType: '',
    caseFlow: '',
    countryOfOrigin: '',
    agency: '',
    proposalForm: '',
    isMaterials: '',
    isFund: '',
    initialPeriod: '',
    referenceNumber: '',
    contractNumber: '',
    budget: '',
    author: '',
    homeLocation: '',
    softwareAbbreviation: '',
    versionNumber: '',
    softwareWorkDescription: '',
    developmentCompletionDateStart: '',
    developmentCompletionDateEnd: '',
    publishedStatus: '',
    hardwareEnvironment: '',
    softwareEnvironment: '',
    programmingLanguage: '',
    sourceQuantity: '',
    functionAndArt: '',
    handlingInformation: '',
    principalDatesStart: '',
    principalDatesEnd: '',
    customerTermStart: '',
    customerTermEnd: '',
    internalWearLifeStart: '',
    internalWearLifeEnd: '',
    isStateCompensation: '',
    click: '',
    partOwner: '',
    todonote: '',
    manageDateStart: '',
    manageDateEnd: '',
    countType: '',
    numberOfPoints: '',
    addtotalstatepoint: '',
    royaltyDateStart: '',
    royaltyDateEnd: '',
    workPoints: '',
    creator: '',
    chargeType: '',
    currency: '',
    sum: '',
    advancePaymentDateStart: '',
    advancePaymentDateEnd: '',
    paymentRequestNumber: '',
    requestedDateStart: '',
    requestedDateEnd: '',
    accountsDateStart: '',
    accountsDateEnd: '',
    invoiceNumber: '',
    chargeName: '',
    chargeDepict: '',
    chargeDepictfine: '',
    extendedAmount: '',
    discountRate: '',
    count: '',
    parities: '',
    collectingCompanyAccount: '',
    collectionStatus: '',
    accountDetails: '',
    sltStart: '',
    sltEnd: '',
    externalBillingNumber: '',
    externalBillingDateStart: '',
    externalBillingDateEnd: '',
    beddingCondition: '',
    handOver: '',
    expenseNote: '',
    reductionType: '',
    actualCurrency: '',
    officialDeadlineStart: '',
    officialDeadlineEnd: '',
    ourRef: '',
    relevantCaseName: '',
    correlationType: '',
    userId: '',
    userName: '',
    updateUserId: '',
    updateUserName: ''
})

const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: caseLists,
    params: queryParams
})

const handleAdd = async () => {
    showEdit.value = true
    await nextTick()
    editRef.value?.open('add')
}

const handleEdit = async (data: any) => {
    showEdit.value = true
    await nextTick()
    editRef.value?.open('edit')
    editRef.value?.getDetail(data)
}

const handleDelete = async (id: number) => {
    await feedback.confirm('确定要删除？')
    await caseDelete({ id })
    feedback.msgSuccess('删除成功')
    getLists()
}

getLists()
</script>
